﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WindowsForms.AOnline.WindowsForm.BaseUserControls;
using WindowsForms.AOnline.View.Dictionary;
using WindowsForms.AOnline.Presenter.Dictionary;
using WindowsForms.AOnline.Presenter.Dictionary.DepartmentTest;
using WindowsForms.AOnline.WindowsForm.FormBase.PropertyGrid;

namespace WindowsForms.AOnline.WindowsForm.UserControl.Dictionary
{
    public partial class UserControlDepartmentTestList1 : BaseTreeListUserControl, IDepartmentTestsView  
    {

        private readonly DepartmentTestsPresenter _DepartmentTestsPresenter;

        public UserControlDepartmentTestList1() 
        {
            InitializeComponent();
            _DepartmentTestsPresenter = new DepartmentTestsPresenter(this);  
        }

         #region IDepartmentsView Members

        /// <summary>
        /// Sets the account categories.
        /// </summary>
        /// <value>The account categories.</value>
        public IList<Model.BusinessObjects.Dictionary.DepartmentTestModel> DepartmentTests   
        {
            set
            {
                treeList.DataSource = value;
                ColumnsCollection.Add(new XtraColumn
                    {
                        ColumnName = "DepartmentId",
                        ColumnCaption = "Mã nhóm tài khoản",
                        ColumnPosition = 1,
                        ColumnVisible = true,
                        ColumnWith = 100
                    });
                ColumnsCollection.Add(new XtraColumn
                    {
                        ColumnName = "Name",
                        ColumnCaption = "Tên nhóm tài khoản",
                        ColumnPosition = 2,
                        ColumnVisible = true,
                        ColumnWith = 300
                    });
                ColumnsCollection.Add(new XtraColumn
                    {
                        ColumnName = "ParentId",
                        ColumnCaption = "Được sử dụng",
                        ColumnVisible = true,
                        ColumnPosition = 3
                    });
                ColumnsCollection.Add(new XtraColumn
                    {
                        ColumnName = "Grade",
                        ColumnCaption = "Tên tiếng anh",
                        ColumnVisible = false,
                        ColumnPosition = 5
                    });
                 ColumnsCollection.Add(new XtraColumn
                    {
                        ColumnName = "Grade",
                        ColumnCaption = "Bậc",
                        ColumnVisible = false,
                        ColumnPosition = 7
                    });
                ColumnsCollection.Add(new XtraColumn
                    {
                        ColumnName = "HasParent",
                        ColumnCaption = "Chi tiết",
                        ColumnVisible = false,
                        ColumnPosition = 8
                    });
            }
        }

        /// <summary>
        /// Loads the data into tree.
        /// </summary>
        protected override void LoadDataIntoTree()
        {
            _DepartmentTestsPresenter.Display();
        }

        /// <summary>
        /// Deletes the tree.
        /// </summary>
        protected override void DeleteTree()
        {
            new DepartmentTestPresenter(null).Delete(int.Parse(PrimaryKeyValue));
        }

        #endregion


        // <summary>
        /// Handles the NodeCellStyle event of the treeList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DevExpress.XtraTreeList.GetCustomNodeCellStyleEventArgs"/> instance containing the event data.</param>
        private void treeList_NodeCellStyle(object sender, DevExpress.XtraTreeList.GetCustomNodeCellStyleEventArgs e)
        {
        //    e.Appearance.Font = Convert.ToBoolean(e.Node["IsDetail"])
        //                            ? new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Regular)
        //                            : new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold);
        }
    

}
}
